<!DOCTYPE html>
<html>

<head lang="en">
    <title>找攻略</title>
    <meta charset="utf-8"/>

    <link rel="stylesheet" href="/js/bootstrap/css/bootstrap.min.css">
    <link rel="stylesheet" href="/css/strategyCatalogs.css"/>
    <link rel="stylesheet" href="/css/strategyComment.css" />
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <link rel="stylesheet" href="/js/plugins/bootstrap-4.1.1-dist/css/bootstrap.min.css">
    <script src="/js/jquery/jquery.min.js"></script>
    <script src="/js/plugins/bootstrap-4.1.1-dist/js/bootstrap.min.js"></script>
    <link rel="stylesheet" href="/css/font/css/font-awesome.min.css"/>
    <link rel="stylesheet" href="/css/reset.css"/>
    <script src="/js/plugins/jrender/jrender.min.js"></script>
    <link rel="stylesheet" href="/js/plugins/jquery-confirm/css/jquery-confirm.css">
    <script src="/js/plugins/jquery-confirm/js/jquery-confirm.js"></script>
    <script src="/js/common.js"></script>
    <script src="/js/plugins/eleditor/Eleditor.min.js"></script>
    <script src="/js/plugins/eleditor/webuploader.min.js"></script>
    <link rel="stylesheet" href="/js/plugins/dialog2/dialog.css">
    <script src="/js/plugins/dialog2/dialog.min.js"></script>
    <script src="/js/plugins/jquery-form/jquery.form.js"></script>



    <script>

        $(function () {

            //检查登录状态
            function checkLogin() {
                if (userStr == null) {
                    $(document).dialog({
                        type: 'confirm',
                        style: 'IOS',
                        titleShow: false,
                        content: '登录后才能评论哟~',
                        buttons: [
                            {
                                name: '取消',
                                callback: function () {
                                }
                            },
                            {
                                name: '确定',
                                callback: function () {
                                    window.parent.location.href = "/login.html";
                                }
                            }
                        ]
                    });
                    return;
                }

            }


            //子评论id和评论id
            var params = getParams();

            //获取当前登录用户信息
            var userStr = sessionStorage.getItem("user");
            var userJSON;

            $("#releaseComment").click(function () {
                if (userStr) {
                    userJSON = JSON.parse(userStr);
                    $("#parentId").val(params.ofCommentId);
                    $("#commentatorId").val(userJSON.id);
                    $("#content").val(Edr.getContent());
                    $("#replyId").val(params.replierId);
                    /*$("#tempContent").val(params.tempContent);*/
                    $("#editForm").ajaxSubmit(function (data) {
                        if (data.success) {
                            $(".fa-commenting-o").attr("class", "fa fa-commenting");
                            $(document).dialog({
                                type: 'confirm',
                                style: 'IOS',
                                titleShow: false,
                                content: '发布成功!',
                                buttons: [
                                    {
                                        name: '确定',
                                        callback: function () {
                                            window.location.href = "/mine/strategyComment.html?id="+ params.commentId;
                                        }
                                    }

                                ]
                            });
                        }
                    });
                }
            });

            //移动富文本框插件
            var Edr = new Eleditor({
                el: '#contentEditor',
                upload: {
                    //图片上传的服务器接口
                    server: '/images',
                    //修改图片接收参数的名称
                    formName: 'pic'
                },
            });
        });

    </script>


</head>

<body>


<div class="comment" id="ofComment">

</div>


<form id="editForm" action="/strategies/strategyOfOfComments" method="post">
    <input type="hidden" name="parentId" id="parentId">
    <input type="hidden" name="commentator.id" id="commentatorId">
    <input type="hidden" name="content" id="content">
    <!--<input type="hidden" name="tempContent" id="tempContent">-->
    <div id="contentEditor" name="content">

    </div>
    <input type="hidden" name="replier.id" id="replyId">

</form>
<div class="comment-list">
    <span>畅所欲言吧!</span>
</div>
<div class="operation">
    <div class="d-flex justify-content-between">
        <div class="p-2" id="releaseComment"><i class="fa fa-commenting-o"></i> 发布你的评论</div>
    </div>
</div>

</body>

</html>